﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PJ.Business.Partner;
using PJ.Data.SalePurchase.Sale;
using PJ.Framework.Common;

namespace PJ.Business.SalePurchase.Sale
{
    /// <summary>
    /// SaleInvoiceItemService class
    /// </summary>
    public class SaleInvoiceService : InvoiceService<ISaleInvoice, ISaleInvoiceData, ISaleInvoiceProvider>, ISaleInvoiceService
    {
        #region Constructor
        //public SaleInvoiceService()
        //    : base(InjectionBroker.Resolve <ISaleInvoiceProvider>())
        //{
        //}

        /// <summary>
        /// Initialize
        /// </summary>
        /// <param name="dataService">Data provider</param>
        /// <param name="customerService">Customer service</param>
        [Microsoft.Practices.Unity.InjectionConstructor]
        public SaleInvoiceService(ISaleInvoiceProvider dataService)
            : base(dataService)
        {
        }

        #endregion

        #region Interface implementation
        /// <summary>
        /// Customer service
        /// </summary>
        public ICustomerService CustomerService
        {
            get
            {
                if (_CustomerService == null)
                    _CustomerService = InjectionBroker.Resolve<ICustomerService>();
                return _CustomerService;
            }
        }
        #endregion

        #region Interface override
        public override IPartnerService PartnerService
        {
            get { return CustomerService; }
        }
        #endregion

        #region Public


        /// <summary>
        /// Create new item implementation
        /// </summary>
        /// <returns>new created item</returns>
        public override ISaleInvoice CreateNewItem()
        {
            return new SaleInvoice(DataService.CreateNewItem());
        }
        #endregion

        #region Field
        private ICustomerService _CustomerService;
        #endregion

    }
}
